package besteAukera;  	 	
 			
 	import java.awt.Color; 		
import java.awt.Font;
 	import java.awt.Graphics; 		
import java.util.Vector;
 			
 	//Oraindik ez dago egina, egindakoa gaizki 		
 	public class DespErregistroa extends Sekuentzialak { 		
	/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
	private Color kolorea; 		
	private Vector<Hanka> hankaBektorea = new Vector<Hanka>(); 		
 	private Vector<Hanka> sarreraBektorea = new Vector<Hanka>(); 		
	private Hanka s1, s2, i1, s3, s4, s5, s6; 		
 			
 	public DespErregistroa(int x1, int y1, int hankaKop, int sarreraKopMax, 		
 	Color kolorea) { 		
	super(x1, y1, hankaKop, sarreraKopMax, kolorea); 		
 	// TODO Auto-generated constructor stub 		
 			
 	s1 = new Hanka(x - 20, y + 10, "positiboa", "s", 0, this, "h", "ez",true); 		
 	s2 = new Hanka(x - 20, y + 34, "positiboa", "s", 1, this, "h", "ez",true); 		
 	s3 = new Hanka(x - 20, y + 46, "negatiboa", "s", 2, this, "h", "ez",true); 		
 	s4 = new Hanka(x + 100, y + 10, "positiboa", "s", 3, this, "h", "bai",true); 		
 	s5 = new Hanka(x + 40, y -20, "positiboa", "s", 4, this, "b", "ez",false); 		
 	s6 = new Hanka(x - 20, y + 22, "positiboa", "s", 5, this, "h", "ez",true); 		
 	i1 = new Hanka(x + 40, y + 80, "positiboa", "i", 6, this, "b", "ez",false); 		
 			
 	lotList[0] = s1; 		
 	lotList[1] = s2; 		
 	lotList[2] = s3; 		
 	lotList[3] = s4; 		
 	lotList[4] = s5; 		
 	lotList[5] = s6; 		
 	lotList[6] = i1; 		
 			
 	} 		
 			
 	public void marraztu(Graphics g) { 		
 			
 	if (getAukeratua() == true) { 		
 	kolorea = Color.GRAY; 		
 	} else { 		
 	kolorea = Color.black; 		
 	} 		
 	g.setColor(kolorea); 		
 	// goikoa 		
 	g.drawLine(x, y, x + 80, y); 		
 	// beikoa 		
 	g.drawLine(x + 80, y, x + 80, y + 60); 		
 	// ezkerretakoa 		
 	g.drawLine(x + 80, y + 60, x, y + 60); 		
 	// eskubitakoa 		
 	g.drawLine(x, y + 60, x, y); 		
 			
 	g.drawLine(x - 10, y + 55, x, y + 55); 		
 	g.drawLine(x - 10, y + 55, x - 10, y + 65); 		
 			
 	// g.drawLine(x - 10, y + 55, x, y + 75); 		
 	// g.drawLine(x - 10, y + 65, x - 10, y + 75); 		
 	Font lehenetsia=g.getFont();
	Font f=new Font("name",Font.BOLD,9);
	g.setFont(f);
 	g.drawString(">", x, y + 60);
	g.drawString(">", x, y + 60);
 	g.drawString("SL", x+5, y + 15);
 	g.drawString("S1", x+5, y + 27);
 	g.drawString("S0", x+5, y + 39);
 	g.drawString("CL*.L", x+5, y + 51);
 	g.drawString("D", x+35, y + 10);
 	g.drawString("SR", x+65, y + 15);
 	g.drawString("Q", x+35, y + 57);
 	g.setFont(lehenetsia);
 	g.setColor(kolorea);
 	s1.marraztu(g); 		
 	s2.marraztu(g); 		
 	i1.marraztu(g); 		
 	s4.marraztu(g); 		
 	s5.marraztu(g); 		
 	s6.marraztu(g); 		
 			
 			
 	s3.marraztu(g); 		
 			
 	} 		
 			
 	public boolean barruanDago(int x, int y) { 		
	if ((x > this.x) && (x < (this.x + 80)) && (y > this.y) 		
 	&& (y < (this.y + 60))) { 		
 	return true; 		
 	} 		
 	return false; 		
 			
 	} 		
 			
 	@Override 		
 	public void funtzioLogikoa(Integer... values) { 		
 			
 	// TODO Auto-generated method stub 		
 	if ((s3.getSarrera().getBalioa() == 1)) { 		
 	lotList[6].getIrteera().setBalioa(0); 		
			
 	} 		
 	else{ 		
 			
 	if ((s6.getSarrera().getBalioa() == 0) && (s2.getSarrera().getBalioa() == 0)) { 		
 	lotList[6].getIrteera().setBalioa(i1.getIrteera().getBalioa()); 		
 			
 	} 		
 	if ((s6.getSarrera().getBalioa() == 0) && (s2.getSarrera().getBalioa() == 1)) { 		
 	if(s4.getSarrera().getBalioa()==0) 		
	//lotList[6].getIrteera().setBalioa(i1.getIrteera().getBalioa()*2); 
 		lotList[6].getIrteera().setBalioa(i1.getIrteera().getBalioa()<<1);
 	if(s4.getSarrera().getBalioa()==1) 		
 	//lotList[6].getIrteera().setBalioa(i1.getIrteera().getBalioa()*2+1); 
 	lotList[6].getIrteera().setBalioa((i1.getIrteera().getBalioa()<<1)+1); 	
 	} 		
 	if ((s6.getSarrera().getBalioa() == 1) 		
 	&& (s2.getSarrera().getBalioa() == 0)) { 		
 	//Cambiar el s1 y ponerle los balores al reves cuando es negativo, no se porke!!!!
 	if(i1.getIrteera().getBalioa()<0){
 		if(s1.getSarrera().getBalioa()==1) 		
 			// 	lotList[6].getIrteera().setBalioa(i1.getIrteera().getBalioa()/2); 	
 			lotList[6].getIrteera().setBalioa(i1.getIrteera().getBalioa()>>1); 
 		if(s1.getSarrera().getBalioa()==0) {		
 			//lotList[6].getIrteera().setBalioa((i1.getIrteera().getBalioa()/2)+(int)Math.pow(2, bitKop-1));
 		
 			lotList[6].getIrteera().setBalioa((i1.getIrteera().getBalioa()>>1)+(int)Math.pow(2, bitKop-1)); 
 		} 
 	}
 	else
 		if(s1.getSarrera().getBalioa()==0) 		
 			// 	lotList[6].getIrteera().setBalioa(i1.getIrteera().getBalioa()/2); 	
 			lotList[6].getIrteera().setBalioa(i1.getIrteera().getBalioa()>>1); 
 		if(s1.getSarrera().getBalioa()==1) {		
 			//lotList[6].getIrteera().setBalioa((i1.getIrteera().getBalioa()/2)+(int)Math.pow(2, bitKop-1));
 		
 			lotList[6].getIrteera().setBalioa((i1.getIrteera().getBalioa()>>1)+(int)Math.pow(2, bitKop-1)); 
 		} 
 	
 	}		
 	if ((s6.getSarrera().getBalioa() == 1) 		
 	&& (s2.getSarrera().getBalioa() == 1)) { 		
 	lotList[6].getIrteera().setBalioa(s5.getSarrera().getBalioa()); 		
 	} 		
 			
 			
 			
 	} 		
 	} 		
 			
 	@Override 		
 	public Vector<Hanka> getHankak() { 		
 	// TODO Auto-generated method stub 		
 	hankaBektorea = new Vector<Hanka>(); 		
 	hankaBektorea.addElement(s1); 		
 	hankaBektorea.addElement(s2); 		
 	hankaBektorea.addElement(s3); 		
 	hankaBektorea.addElement(s4); 		
 	hankaBektorea.addElement(s5); 		
 	hankaBektorea.addElement(s6); 		
 	hankaBektorea.addElement(i1); 		
 			
 	return hankaBektorea; 		
 	} 		
 			
 	@Override 		
 	public Vector<Hanka> getSarreraHankak() { 		
 	// TODO Auto-generated method stub 		
 	sarreraBektorea = new Vector<Hanka>(); 		
 	sarreraBektorea.addElement(s1); 		
 	sarreraBektorea.addElement(s2); 		
 	sarreraBektorea.addElement(s3); 		
 	sarreraBektorea.addElement(s4); 		
 	sarreraBektorea.addElement(s5); 		
 	sarreraBektorea.addElement(s6); 		
 			
 	return sarreraBektorea; 		
 	} 		
 			
 	} 		


